package local;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNextLine()) {
			String day = in.nextLine();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			try {
				Date beginDate = sdf.parse("1990-01-01");
				Date endDate = sdf.parse(day);
				Calendar cal = Calendar.getInstance();
				cal.setTime(beginDate);
				long bt = cal.getTimeInMillis();
				cal.setTime(endDate);
				long et = cal.getTimeInMillis();
				long days = (et-bt)/(1000*3600*24);
				
				if(!sdf.format(endDate).equals(day)) {
					System.out.println("Invalid input");
					break;
				}
				
				
				if(days%5 >2) {
					System.out.println("He is having a rest");
				}else {
					System.out.println("He is working");
				}
			} catch (ParseException e) {
				
			}
		}
	}

//    int res=0;
//    String mnString = in.nextLine();
//    String[] mn = mnString.split(" ");
//    int m =Integer.valueOf(mn[0]),n = Integer.valueOf(mn[1]);
//    int[][] nums = new int[m][n];
//    int[][] maps = new int[m][n];
//    for(int i=0;i<m;i++) {
//    	String rowString = in.nextLine();
//    	String[] row = rowString.split(" ");
//    	for(int j=0;j<row.length;j++) {
//        	nums[i][j] = Integer.valueOf(row[j]);
//        }
//    }
//    
//    for(int i=0;i<nums.length;i++) {
//    	for(int j=0;j<nums[0].length;j++) {
//    		if(nums[i][j]==1 && maps[i][j]==0) {
//    			res++;
//    			isIsland(i,j,maps,nums,res);
//    		}
//    	}
//    }
//    System.out.println(res);
	public static void isIsland(int i, int j, int[][] maps, int[][] nums, int res) {
		if (i < 0 || j < 0 || i >= maps.length || j >= maps[0].length) {
			return;
		}
		if (nums[i][j] == 1 && maps[i][j] == 0) {
			maps[i][j] = res;
			isIsland(i + 1, j, maps, nums, res);
			isIsland(i - 1, j, maps, nums, res);
			isIsland(i, j + 1, maps, nums, res);
			isIsland(i, j - 1, maps, nums, res);
		}
	}
}
